export {};

// let salary1 = "1万元";
// let salary2 = 10000;

//联合类型
let salary: string | number;

salary = "1万元";
salary = 10000;

let age: string | number;
age = "5岁半";
age = 5.5;

type MyStringNumber = string | number;

let snVar: MyStringNumber;
snVar = "aaaa";
snVar = 100;

//给类型起别名
type myNum = number;
let n1: myNum = 1000;

// 定义类型
type User = { username: string; password?: string };

let user: User = {
  username: "admin",
  password: "123456",
};

let user2: User = {
  username: "admin",
  password: "123456",
};

type Address = {
  province: string;
  city: string;
};
let myadd1: Address = {
  province: "黑龙江",
  city: "哈尔滨",
};

// type OrderRe = {
//   username: string;
//   province: string;
//   city: string;
// };

//交叉类型
type OrderRe = Address & User;

let myOrderRe: OrderRe = {
  province: "黑龙江",
  city: "哈尔滨",
  username: "张三",
};

type gender = "男" | "女";

function showInfo(gender: gender): void {
  if (gender == "男") {
    console.log("大概在60--63之间退休");
  }
  if (gender == "女") {
    console.log("大概在55-58之间退休");
  }
}

// ok
showInfo("女");

//  fail 类型“"男士"”的参数不能赋给类型“gender”的参数
// showInfo("男士");
